// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'

//d3.js
import * as d3 from 'd3'
// 引入echarts
import echarts from "echarts"
//jquery
import $ from 'jquery'

//bootstrap
import 'bootstrap/dist/css/bootstrap.min.css'
import 'bootstrap/dist/js/bootstrap.min.js'

//excel viewer
import vueXlsxTable from 'vue-xlsx-table'
Vue.use(vueXlsxTable,{rABS: true}) 
//Browser FileReader API have two methods to read local file readAsBinaryString and readAsArrayBuffer, default rABS false
//静态文件base.css
require('./assets/css/base.css')

Vue.config.productionTip = false
// to 进入 from 离开 next 传递
router.beforeEach((to, from, next) => {
    if (to.matched.some(record => record.meta.requiresAuth)) {
        //这里判断用户是否登录,验证本地存储是否有token
        if (localStorage.getItem('token')==null || localStorage.getItem('token')=='') {
            next({
            	path: '/login',
                query: { redirect: to.fullPath }
            })
        }else {
          next()
        }
    } else {
      next() // 确保一定要调用 next()
    }
})

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  template: '<App/>',
  components: { 
  		App
  }

})
